//
//  MyNavigationController.m
//  Test
//
//  Created by xueshan1 on 2019/5/31.
//  Copyright © 2019 xueshan1. All rights reserved.
//

#import "MyNavigationController.h"

@interface MyNavigationController ()<UIGestureRecognizerDelegate>

@end

@implementation MyNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    id target = self.interactivePopGestureRecognizer.delegate;
    
    SEL handler = NSSelectorFromString(@"handleNavigationTransition:");
    
    UIView *handleView = self.interactivePopGestureRecognizer.view;
//
//    UIPanGestureRecognizer *panFullScreen = [[UIPanGestureRecognizer alloc]initWithTarget:target action:handler];
//    panFullScreen.delegate = self;
//    [handleView addGestureRecognizer:panFullScreen];
//
//    self.interactivePopGestureRecognizer.enabled = NO;
    
    UIRectEdge edge = [(UIScreenEdgePanGestureRecognizer *)self.interactivePopGestureRecognizer edges];

 
}

- (UIScreenEdgePanGestureRecognizer *)screenEdgePanGestureRecognizer {
    UIScreenEdgePanGestureRecognizer *screenEdgePanGestureRecognizer = nil;
    if (self.navigationController.view.gestureRecognizers.count > 0) {
        for (UIGestureRecognizer *recognizer in self.navigationController.view.gestureRecognizers) {
            if ([recognizer isKindOfClass:[UIScreenEdgePanGestureRecognizer class]]) {
                screenEdgePanGestureRecognizer = (UIScreenEdgePanGestureRecognizer *)recognizer;
                break;
            }
        }
    }
    return screenEdgePanGestureRecognizer;
}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
    if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
        CGPoint translation = [(UIPanGestureRecognizer *)gestureRecognizer translationInView:gestureRecognizer.view];
        if (translation.x < 0) {
            return NO;
        }
        if ([[self valueForKey:@"_isTransitioning"] boolValue]) {
            return NO;
        }
    }

    return YES;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    if ([NSStringFromClass([touch.view class])    isEqualToString:@"UITableViewCellContentView"]) {
//        return NO;
    }
    return YES;
}


@end
